<%@ page import="top.fyxxxx.dbdesign.dao.DBoperate" %>
<%@ page import="java.util.Set" %>
<%@ page import="top.fyxxxx.dbdesign.data.PersonalData" %>
<%@ page import="top.fyxxxx.dbdesign.util.Reporter" %>
<%--
  Created by IntelliJ IDEA.
  User: WZL
  Date: 2020/5/4
  Time: 23:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    Reporter reporter=Reporter.getInstance();
    DBoperate dBoperate=DBoperate.getInstance();
    double process=0;
    if(session.getAttribute("uid")==null)request.getRequestDispatcher("/index.jsp").forward(request,response);
    long uid=(Long)session.getAttribute("uid");
    //long uid=1590064934429L;
    long cid=Long.parseLong(request.getParameter("cid"));

%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>查看班级成员</title>
    <link rel="stylesheet" type="text/css" href="inf.css">
    <link rel="stylesheet" type="text/css" href="bar.css">
    <link rel="stylesheet" type="text/css" href="boxAndButton.css">
</head>
<body>

<div style="text-align: center"><p class="title"><a href="teacherMainPage.jsp">返回首页</a></p></div>
<div id="content" >
    <div style="text-align: center">
        <p class="title"><%=dBoperate.getCourse(cid).getName()%></p>
    </div>

    <section class="container">

        <%
            Set<Long> uidSet=dBoperate.getCourse(cid).getMemberUid();
            for(long studentUid:uidSet){
                if(studentUid==uid)continue;
                String t="";
                PersonalData personalData= Reporter.getInstance().getPersonalData(uid,studentUid,cid);
                if(personalData==null){
                    response.sendRedirect("login.jsp");
                }
                int signInNum=personalData.getSignInNum();
                int unsignInNum=personalData.getUnSignInNum();
                process=(double)signInNum/(signInNum+unsignInNum)*100;
                if (process<60-1e-8)t="red";
                else if(process<100-1e-8)t="yellow";
                else t="green";
        %>

        <a style="text-decoration:none" href="informationDetail.jsp?cid=<%=cid%>&uid=<%=studentUid%>">
            <%=dBoperate.getAccountByUid(studentUid).getName()%></a>
        <p style="font-size: 10px;float: right">签到次数:<%=signInNum%>次  未签到次数<%=unsignInNum%>次</p>
        <div class="progress">
            <span class="<%=t%>" style="width: <%=process%>%"><span><%=process%>%</span></span>
        </div>
        <%
            if(dBoperate.getCourse(cid).getCreateByUid()==uid){
            if(!reporter.checkAdmin(studentUid,cid)){
        %>
        <div class="joinBox" >
            <button
                    onclick="location='setAdminServlet?cid=<%=cid%>&uid=<%=studentUid%>'"
            >设置管理员</button>
        </div>
        <%
            }
            else{
        %>
        <div class="deleteBox"  style="margin-bottom: 0px">
            <button
                    onclick="location='setAdminServlet?cid=<%=cid%>&uid=<%=studentUid%>'"
            >撤销管理员</button>
        </div>
        <%
            }
        %>
        <br>
        <br>
        <hr>
        <%
                }
            }
        %>
    </section>

</div>


</body>
</html>
